//
//  BCNetAPIClient.h
//  BCShop
//
//  Created by sheweicai on 15/6/1.
//  Copyright (c) 2015年 美丽点击. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"
#import "APIUrl.h"

typedef enum {
    Get = 0,
    Post =1,
    Put,
    Delete
} NetworkMethod;

typedef void (^RequestCompleteBlock)(id response);
typedef void (^RequestErrorBlock)(NSError *errorInfo);

typedef void (^HttpSuccessBlock) (id JSON);
typedef void (^HttpFailureBlock) (NSError *error);

@interface BCNetAPIClient : AFHTTPRequestOperationManager

+ (id)sharedJsonClient;
+ (void)saveCookieData;
+ (void)removeCookieData;
- (void)refreshToken;

/*
+(BCNetAPIClient *)sharedJsonClientProduct;

测试
+(BCNetAPIClient *)sharedJsonTestClientProduct;
*/
- (void)requestJsonDataWithPath:(NSString *)aPath
                     withParams:(NSDictionary*)params
                 withMethodType:(NetworkMethod)NetworkMethod
                       andBlock:(void (^)(id data, NSError *error, AFHTTPRequestOperation *operation))block;

/**
 *网络数据请求
 @param requestUrl:请求的地址
 @param parameter:请求的参数
 @param showProgress:是否显示网络请求loading
 @param showAlert:是否在网络出现问题的时候出现弹窗
 @param completionBlock:请求成功的回调
 @param errorBlock:请求结果失败的回调
 @return
 */
- (void)requestJsonDataWithUrl:(NSString *)requestUrl
                     withParams:(NSDictionary*)params
                withMethodType:(NetworkMethod)NetworkMethod showProgress:(BOOL)showProgress
                       showNetworkErrorAlert:(BOOL)showAlert onCompletion:(RequestCompleteBlock)completionBlock onError:(RequestErrorBlock)errorBlock;

+(void)uploadImage:(NSString *)url andParameters:(NSDictionary *)parameters andImage:(UIImage *)image progress:(void(^)(NSProgress *progress))progress success:(void (^)(id responseObject))success failure:(void (^)(NSError *failure))failure;



//- (NSURLSessionDataTask *)dataTaskWithRequest:(NSMutableURLRequest *)urlRequest completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))originalCompletionHandler;

//- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)request
//                                                    success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
//                                                    failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;


// ************************************************ -视频上传- ************************************************

+ (void) upLoadVideoWithOption:(NSDictionary *)para withInferface:(NSString *)requestURL videoPath:(NSURL *)videoURL uploadSuccess:(void (^)(AFHTTPRequestOperation * , id))success uoloadFailure:(void (^)(AFHTTPRequestOperation *, NSError *))failure progress:(void (^)(float))progress;

// 12.19 test
+ (void)postWithImgPath:(NSString *)path
                 params:(NSDictionary *)params
                 images:(NSArray *)images
                success:(void(^)(id responseObject))success
                failure:(void(^)(NSError *error))failure;


+ (void)PostVideosAndImages:(NSString *)path parameters:params imageArray:(NSArray *)imagesArr videoArray:(NSString *)videoStr success:(void(^)(id responseObjecet))success failure:(void(^)(NSError *error))failure;


+ (void)PostVideosAndImages:(NSString *)path parameters:params videoArray:(NSString *)videoStr success:(void(^)(id responseObjecet))success failure:(void(^)(NSError *error))failure;









@end
